<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>修改密码</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3 class="text-center">修改密码</h3>
                    </div>
                    <div class="card-body">
                        <form th:action="@{/user/password}" method="post" onsubmit="return validateForm()">
                            <div class="mb-3">
                                <label for="oldPassword" class="form-label">原密码</label>
                                <input type="password" class="form-control" id="oldPassword" name="oldPassword" required>
                            </div>
                            <div class="mb-3">
                                <label for="newPassword" class="form-label">新密码</label>
                                <input type="password" class="form-control" id="newPassword" name="newPassword" required>
                            </div>
                            <div class="mb-3">
                                <label for="confirmPassword" class="form-label">确认新密码</label>
                                <input type="password" class="form-control" id="confirmPassword" required>
                            </div>
                            <div class="text-danger mb-3" th:if="${error}" th:text="${error}"></div>
                            <button type="submit" class="btn btn-primary w-100 mb-3">修改密码</button>
                            <div class="text-center">
                                <a th:href="@{/product/search}" class="text-decoration-none">返回首页</a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        function validateForm() {
            var newPassword = document.getElementById('newPassword').value;
            var confirmPassword = document.getElementById('confirmPassword').value;
            
            if (newPassword !== confirmPassword) {
                alert('两次输入的新密码不一致');
                return false;
            }
            return true;
        }
    </script>
</body>
</html> 